
package Objects;

import GameEngine.GameConstants.Effect;
import GameEngine.GameConstants.Graphic;
import GameEngine.GameConstants.Material;
import GameEngine.Vector;

/**
 *
 * @author mhfowler
 */
public class Portal extends GameObject {


     Vector teleportTo;
                /**
     * A constructor
     * @param dir
     * @param min
     * @param max
     */
    public Portal(Vector m, Vector cen, Vector s) {
        super(m, cen, s, Graphic.PORTAL);
        material = Material.PORTAL;
        graph = Graphic.PORTAL;
        teleportTo = new Vector(0,0);
        isTangible = false;
    }

    public void linkPortals(Portal p) {
        teleportTo = p.center.addNew(center.scaleNew(-1.0));
        p.linkPortals(this);
    }

    public void setTeleportTo(Vector v) {
        teleportTo = v;
    }


    @Override
    public void receiveEffect(Effect e, Vector m, int power) {
        switch (e) {
            default:
                super.receiveEffect(e, m, power);
                break;
        }
    }

    @Override
    public void collide(GameObject o) {
        switch (o.material) {
            default:
                o.receiveEffect(Effect.TELEPORT, teleportTo, 0);
                break;
        }
    }


}
